<!--#include file="./load.inc"-->
<%
dim qid, query, url, temp

if isHtml then
	qid = lcase(trim(request("q"))) 'rss|hits|check
else
	temp = lcase(request.serverVariables("QUERY_STRING"))
	url = app.isTest(temp, "^\/(rss|hits|check)+\.(" & replace(fileExt, ".", "") & "|xml)+[&|?]*(.*?)$")
	if isArray(url) and ubound(url) > 0 then
		qid = url(0)
	end if
end if

set query = new queryControl
select case qid
	case "rss"		:	query.getRss() 'rss
	'case "go"		:	app.go(trim(request("url")))
	case "hits"		:	query.getHits() '点击数
	'case "check" '验证产品
	case else		:	app.message "恭喜你！猜对了！"
end select

call db.close()

class queryControl
	public function getHits()
		call app.checkPost()
		dim rs, cid, iid, infoType
		cid = app.int(request.form("g"))
		iid = app.int(request.form("i"))
		infoType = ""
		if cid > 0 and iid > 0 then
			select case cid
				case 1 : infoType = "product"
				case 2 : infoType = "book"
				case 3 : infoType = "news"
			end select
			if infoType <> "" then
				call db.exec("update cj_" & infoType & " set hits=hits+1 where id=" & iid, 1)
			end if
		end if
	end function

	public function getRss()
		dim rs, sql(2), str, i, j, data
		response.contentType = "text/xml"
		if app.fileCacheExpire("rss") then
			siteName = app.noCode(siteName)
			siteTitle = app.noCode(app.reConfig(siteTitle))
			str = "<?xml version=""1.0"" encoding=""utf-8""?>" & vbCr & "<rss version=""2.0"">" & vbCr
			str = str & "<channel>" & vbCr 'document channel
			str = str & "	<title>" & siteTitle & "</title>" & vbCr
			str = str & "	<description>" & app.noCode(app.getConfig("metadescription")) & "</description>" & vbCr
			str = str & "	<link>" & siteUrl & "</link>" & vbCr
			str = str & "	<Currentlink>" & app.getUrl("rss","","") & "</Currentlink>" & vbCr
			str = str & "	<image>" & vbCr
			str = str & "		<title>" & siteTitle & "</title>" & vbCr
			str = str & "		<url>" & siteUrl & app.reConfig(app.getConfig("logoUrl")) & "</url>" & vbCr
			str = str & "		<link>" & siteUrl & "</link>" & vbCr
			str = str & "	</image>" & vbCr
			str = str & "	<language>zh-cn</language>" & vbCr
			str = str & "	<docs>" & siteName & "</docs>" & vbCr
			str = str & "	<copyright>Powered by www.cjasp.com. Copyright &#169; " & year(Date) & "</copyright>" & vbCr
			str = str & "	<generator>赤金企业网站程序</generator>" & vbCr
			
			sql(0) = "select top 60 id,title,author,content,dateTime,className from cj_news A, cj_class B where auditing=true and A.classID=B.classID Order By id desc"
			sql(1) = "select top 60 id,title,manufacturer,content,dateTime,className from cj_product A, cj_class B where A.isStop=false and A.classID=B.classID Order By id desc"
			sql(2) = "select top 60 id,title,userName,content,dateTime,className from cj_book A, cj_class B where auditing=true and replyID=0 and A.classID=B.classID Order By id desc"
			for j = 0 to ubound(sql)
				data = db.getData(sql(j))
				if isArray(data) then
					for i = 0 to ubound(data, 2)
						dim tem
						tem = app.noCode(data(5,i))
						str = str & "	<item>" & vbCr
						str = str & "		<title>" & tem & "-" & app.noCode(data(1,i)) & "</title>" & vbCr
						str = str & "		<link>" & app.getInfoUrl(3,data(0,i),1) & "</link>" & vbCr
						str = str & "		<description>" & left(app.noCode(data(3,i)), 200) & "...</description>" & vbCr
						str = str & "		<author>" & data(2,i) & "</author>" & vbCr
						str = str & "		<category>" & tem & "</category>" & vbCr
						str = str & "		<pubDate>" & rssDate(data(4,i)) & "</pubDate>" & vbCr
						str = str & "	</item>" & vbCr
					next
				end if
			next
			str = str & "</channel>" & vbCr 'document
			str = str & "</rss>"
			app.fileCacheWrite "rss", str
		else
			str = app.fileCacheLoad("rss") '读取缓存
		end if
		response.write str
	end function

	public function rssDate(ByVal sDate)
		dim str
		str = getLocale()
		SetLocale("en-gb")
		sDate = app.cj_date(sDate)
		rssDate = WeekDayName(weekday(sDate), true) & "," & right("0" & day(sDate), 2) & " " &_
		MonthName(month(sDate), true) & " " & year(sDate) & " " & right("0" & hour(sDate), 2) & ":" &_
		right("0" & minute(sDate), 2) & ":" & right("0" & second(sDate), 2) & " +0800"
		SetLocale(str)
	end function
end class
%>